<template>
  <div class="percent">
    <div class="title">
      {{percent.title}}
    </div>
    <div class="percent-content">
      <div class="percent-bar">
        <div class="empty">
          <span class="empty-box" v-for="(item, index) of emptyColor" :key="index" :style="{backgroundColor: item}"></span>
        </div>
        <div class="full">
          <span class="full-box" v-for="(item, index) of fullColor" :key="index" :style="{backgroundColor: item}"></span>
        </div>
      </div>
      <div class="percent-num">
        30%
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'ChartPercent',
  props: {
    percent: Object
  },
  data () {
    return {
      emptyColor: ['#313d32', '#313d32', '#313d32', '#313d32', '#313d32', '#313d32', '#313d32', '#313d32', '#313d32', '#313d32', '#313d32', '#443c2a', '#443c2a', '#443c2a', '#443c2a', '#443c2a', '#44282e', '#44282e', '#44282e', '#44282e'],
      fullColor: ['#6aaf62', '#6aaf62', '#6aaf62', '#6aaf62', '#6aaf62', '#6aaf62', '#6aaf62', '#6aaf62', '#6aaf62', '#6aaf62', '#6aaf62', '#e0b239', '#e0b239', '#e0b239', '#e0b239', '#e0b239', '#d54354', '#d54354', '#d54354', '#d54354']
    }
  }
}
</script>
<style lang="scss">
  .percent{
    width: 100%;
    background-color: #070c1e;
    border: 1px solid #01040f;
    border-radius: 2px;
    .title{
      font-size: 12px;
      color: #fff;
      line-height: 30px;
      height: 30px;
      text-align: left;
      text-indent: 0.5rem;
    }
    .percent-content{
      display: flex;
      flex-direction: row;
      align-items: center;
      padding: 3px 8px;
      .percent-bar{
        flex: 1;
        position: relative;
        .empty{
          display: flex;
          flex-direction: row;
          justify-content: space-between;
          width: 100%;
          height: 50px;
          padding-right: 10px;
          .empty-box{
            display: inline-block;
            width: calc((100% - 80px)/20);
            height: 50px;
            border-radius: 2px;
          }
        }
        .full{
          display: flex;
          flex-direction: row;
          justify-content: space-between;
          position: absolute;
          top: 0;
          left: 0;
          z-index: 3;
          width: 100%;
          height: 50px;
          padding-right: 10px;
          .full-box{
            display: inline-block;
            width: calc((100% - 80px)/20);
            height: 50px;
            border-radius: 2px;
          }
        }
      }
      .percent-num{
        font-size: 24px;
        color: #6aaf62;
      }
    }
  }
</style>